/*
 * windowstore.h - class that maintains list of windows/tabs
 * Copyright (C) 2009  Sergei Stolyarov
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * Kajim::ChatInputText widget implements basic functions required
 * by chat text entry widget: history navigation, autocompletion etc
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

#ifndef WINDOWSTORE_H
#define WINDOWSTORE_H
#include <QObject>

struct QWidget;

struct RosterWindow;

namespace Kajim
{

namespace Common
{
    struct ContentContainerWidget;
}

struct ChatWidget;

/**
 * This singleton class maintains list of chat windows/tabs.
 * \class Kajim::WindowStore
 */
class WindowStore : public QObject
{
    Q_OBJECT
public:
    static WindowStore * instance();

    ~WindowStore();
    /**
     * Get window/tab for given chat or exiting window/tab that contain given chat.
     * @param chat
     * @return
     */
    QWidget * chatWindow(Common::ContentContainerWidget * chat);

    /**
     * Get pointer to roster window, create it if it doesn't exist yet.
     * @return
     */
    RosterWindow * rosterWindow();

public slots:
    void updateLayout();

protected:
    /**
     * Create window for given content widget
     * @param content usually it's a ChatWidget instance
     * @return pointer to created window instance
     */
    QWidget * createContentContainer(Common::ContentContainerWidget * content);

protected slots:
    void dialogClose();

private:
    WindowStore(QObject * parent = 0);
    static WindowStore * inst;
    struct Private;
    Private * d;
};
}
#endif
